Skip to content

Conversation

@HernaniSamuel
Copy link

@HernaniSamuel HernaniSamuel commented Jan 23, 2026

Clarify that the objects listed in the free-threading HOWTO are additional immortalizations specific to the free-threaded build.

This addresses the inconsistency reported in #144161, where sys.intern() documentation states that interned strings are not immortal, while the free-threading HOWTO suggested otherwise. Both are correct for their respective contexts (default vs. free-threaded builds).

Changes follow the suggestion by @Prometheus3375 in the issue discussion.


📚 Documentation preview 📚: https://cpython-previews--144176.org.readthedocs.build/

…build

Clarify that the objects listed in the free-threading HOWTO are
additional immortalizations specific to the free-threaded build.
This addresses the inconsistency with sys.intern() documentation,
which describes the default (mortal) behavior.
@python-cla-bot
Copy link

python-cla-bot bot commented Jan 23, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Copy link
Contributor

@sharktide sharktide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make much more sense to just add a note to sys.intern and PyUnicode_InternInPlace saying that the free-threaded build makes all interned strings immortal.

Copy link
Contributor

@Prometheus3375 Prometheus3375 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though perhaps in both "Note" blocks I would also highlight "are" in bold as on the picture below.

Image

Comment on lines 1753 to 1755
Note that interned strings are not “immortal”.
You must keep a reference to the result to benefit from interning.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to avoid double "Note", here's rephrase of the previous paragraph.

Suggested change
Note that interned strings are not immortal.
You must keep a reference to the result to benefit from interning.
Interned strings are not :term:`immortal`.
You must keep a reference to the result to benefit from interning.

You must keep a reference to the result to benefit from interning.
.. note::
On the free-threaded build, all interned strings are :term:`immortal`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I messed up the suggestion, the right term is "free threading":

Suggested change
On the free-threaded build, all interned strings are :term:`immortal`.
On the :term:`free threaded <free threading>` build, all interned strings are :term:`immortal`.

Copy link
Contributor

@Prometheus3375 Prometheus3375 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that every line is at max 80 chars and has no trailing spaces. Because of term links added, some of the changes violate this.

You must keep a reference to the result to benefit from interning.
.. note::
On the :term:`free threaded <free threading>` build, all interned strings are :term:`immortal`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On the :term:`free threaded <free threading>` build, all interned strings are :term:`immortal`.
On the :term:`free threaded <free threading>` build,
all interned strings are :term:`immortal`.

return value of :func:`intern` around to benefit from it.

.. note::
On the :term:`free threaded <free threading>` build, all interned strings are :term:`immortal`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On the :term:`free threaded <free threading>` build, all interned strings are :term:`immortal`.
On the :term:`free threaded <free threading>` build,
all interned strings are :term:`immortal`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants